﻿Imports System.Runtime.CompilerServices

Module Program
    Sub Main()
        Mostrar_Array()
        Console.WriteLine("-----")

        Mostrar_List()
        Console.WriteLine("-----")

        Mostrar_Dictionary()
        Console.WriteLine("-----")

        Mostrar_Custom()
        Console.WriteLine("-----")
    End Sub

#Region "Array"

    Sub Mostrar_Array()
        Dim valores = {10, 13, 17, 19}

        For Each v In valores
            Console.WriteLine("Valor: {0}", v)
        Next
    End Sub

#End Region

#Region "List"

    Sub Mostrar_List()
        Dim listaDeNomes = New List(Of String) From
        {
            "Carlos",
            "Rita",
            "Marcos",
            "Joana"
        }

        For Each n In listaDeNomes
            Console.WriteLine("Nome: {0}", n)
        Next
    End Sub

#End Region

#Region "Dictionary"

    Sub Mostrar_Dictionary()
        Dim dicionarioDeNomes = New Dictionary(Of Integer, String) From
        {
            {1, "Filipe"},
            {2, "José"}
        }

        For Each e In dicionarioDeNomes
            Console.WriteLine("Id: {0}, Nome: {1}", e.Key, e.Value)
        Next
    End Sub

#End Region

#Region "Custom"

    Sub Mostrar_Custom()
        Dim listaDeClientes = New List(Of Cliente) From
        {
            {1, "Luís", "Fernandes"},
            {2, "Maria", "Silva"}
        }

        For Each c In listaDeClientes
            Console.WriteLine("Id: {0}, Nome: {1} {2}", c.Id, c.Nome, c.Apelido)
        Next
    End Sub

    <Extension()>
    Public Sub Add(ByVal list As List(Of Cliente),
                   ByVal id As Integer,
                   ByVal nome As String,
                   ByVal apelido As String)

        list.Add(New Cliente With
        {
            .Id = id,
            .Nome = nome,
            .Apelido = apelido
        })
    End Sub

#End Region

End Module
